package com.example.sentinel.compoment;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 全局异常处理
 *
 * @author zxs
 * @version 1.0
 * @date 2017年3月7日
 */
@ControllerAdvice
public class GlobalExceptionHandler {


    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);



    @ExceptionHandler(Exception.class)
    @ResponseBody
    public void exceptionHandler(Exception e, HttpServletRequest request) {
        e.printStackTrace();
        logger.error(e.getMessage());
    }
}
